package com.sudichina.sudichina.view.activity.dentification;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.sudichina.sudichina.Contains;
import com.sudichina.sudichina.R;
import com.sudichina.sudichina.bean.Car;
import com.sudichina.sudichina.view.activity.main.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CarDetailActivity extends BaseActivity {

    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_right)
    TextView tvRight;
    //状态
    @BindView(R.id.tv_acd_state)
    TextView tvAcdState;
    //车牌
    @BindView(R.id.tv_acd_chepai)
    TextView tvAcdChepai;
    //车型
    @BindView(R.id.tv_acd_carshape)
    TextView tvAcdCarshape;
    //车长
    @BindView(R.id.tv_acd_carlength)
    TextView tvAcdCarlength;
    //载重
    @BindView(R.id.tv_acd_capacity)
    TextView tvAcdCapacity;
    //体积
    @BindView(R.id.tv_acd_bulk)
    TextView tvAcdBulk;
    //发动机
    @BindView(R.id.tv_acd_motor)
    TextView tvAcdMotor;
    //驾驶证
    @BindView(R.id.iv_acd_carcard)
    ImageView ivAcdCarcard;
    //车的图片
    @BindView(R.id.iv_acd_car)
    ImageView ivAcdCar;

    @BindView(R.id.bt_acdp_confim)
    Button btAcdpConfim;
    @BindView(R.id.activity_car_detail)
    LinearLayout activityCarDetail;
    private Car mCar;
    private String ceshi;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_car_detail);
        ButterKnife.bind(this);
        try {
            mCar = getIntent().getParcelableExtra(Contains.CAR_TO_DETAIL);
            System.out.println(mCar.toString() + "车辆详情");
        } catch (Exception e) {
        }

        initData();


    }

    private void initData() {
        tvTitle.setText("车辆详情");
        tvRight.setVisibility(View.VISIBLE);
        tvRight.setText("修改");
        //状态
        int auditStatus = mCar.getAuditStatus();
        switch (auditStatus) {
            case 0:
                tvAcdState.setText("审核中 >");
                break;
            case 2:
                tvAcdState.setText("已通过 >");
                break;
            case 3:
                tvAcdState.setText("未通过 >");
                break;
        }
        //车牌号
        tvAcdChepai.setText(mCar.getCarFirstLetter() + mCar.getCardNumber());
//车型

//        tvAcdCarshape.setText(mCar.get);
        //车长
        tvAcdCarlength.setText(mCar.getCarLenght()+"");
        tvAcdCapacity.setText(mCar.getCarWeight()+"");
        tvAcdBulk.setText(mCar.getCarCube()+"");
        tvAcdMotor.setText(mCar.getEngineNum()+"");
        ceshi = "http://www.jcodecraeer.com/uploads/20140731/67391406772378.png";
//        Picasso.with(getApplicationContext())
//                .load(ceshi)
//.resize(50,50)
//                .centerCrop()
//                .into(ivAcdCarcard);
        String driveLicensePath2 = mCar.getDriveLicensePath2();
        String s="http://www.sudichina.com"+driveLicensePath2;
        Picasso.with(getApplicationContext()).load(s).into(ivAcdCar);
        Picasso.with(getApplicationContext()).load(ceshi).into(ivAcdCarcard);



    }

   @OnClick({R.id.iv_back, R.id.iv_acd_carcard, R.id.iv_acd_car, R.id.bt_acdp_confim,R.id.tv_right})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;


            case R.id.bt_acdp_confim:
                break;
            case R.id.tv_right:
                Intent intent = new Intent(this, CarIdentificationActivity.class);
                intent.putExtra("mCar",mCar);
                startActivity(intent);

                break;
        }
    }
}
